import { treeData } from '@/api/commonApi.js'
export default {
  components: {
  },
  data() {
    return {
      treeData: []
    }
  },
  created() {
    this.getTreeData()
  },
  watch: {
  },
  beforeMount() {
  },
  beforeDestroy() {
  },
  mounted() {
  },
  methods: {

    getTreeData() {
      treeData().then(res => {
        this.treeData = res.data.list
        // this.isChild(res.data.list)
      })
    },
    // 递归拿到一个默认值 好像不用递归。固定三层
    // 树形结构懒加载 已弃用
    isChild(list) {
      for (var i = 0; i < list.length; i++) {
        // list[i].leaf=true
        for (var j = 0; j < list[i].child.length; j++) {
          list[i].child[j].leaf = true
          for (var k = 0; k < list[i].child[j].child.length; k++) {
            list[i].child[j].leaf = false
          }
        }
      }
      console.log(list)
      this.treeData = list
    }

  }
}
